package com.avic.common.convertor;


import com.avic.controller.info.EmergencyResourceInfo;
import com.avic.dal.model.EmergencyResource;

import java.util.ArrayList;
import java.util.List;

public class EmergencyResourceConvertor {

    public static List<EmergencyResourceInfo> emergencyResourcesToEmergencyResourceInfo(List<EmergencyResource> emergencyResources) {
        if (null != emergencyResources && emergencyResources.size() > 0) {
            List<EmergencyResourceInfo> emergencyResourceInfos = new ArrayList<>();
            emergencyResources.forEach(carResource -> {
                emergencyResourceInfos.add(emergencyResourceToEmergencyResourceInfo(carResource));
            });
            return emergencyResourceInfos;
        }
        return new ArrayList<>();
    }

    public static EmergencyResourceInfo emergencyResourceToEmergencyResourceInfo(EmergencyResource emergencyResource) {
        if (null != emergencyResource) {
            EmergencyResourceInfo emergencyResourceInfo = new EmergencyResourceInfo();
            emergencyResourceInfo.setCreateTime(emergencyResource.getCreateTime());
            emergencyResourceInfo.setId(emergencyResource.getId());
            emergencyResourceInfo.setResourceCount(emergencyResource.getResourceCount());
            emergencyResourceInfo.setResourceDept(emergencyResource.getResourceDept());
            emergencyResourceInfo.setResourceLeader(emergencyResource.getResourceLeader());
            emergencyResourceInfo.setResourceName(emergencyResource.getResourceName());
            emergencyResourceInfo.setResourceNumber(emergencyResource.getResourceNumber());
            emergencyResourceInfo.setResourceType(emergencyResource.getResourceType());
            emergencyResourceInfo.setResourcePurpose(emergencyResource.getResourcePurpose());
            return emergencyResourceInfo;
        }
        return null;
    }
}
